<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>许愿墙</title>
    <link rel="stylesheet" href="/wish/Public/Css/index.css">
    <script src="/wish/Public/Js/jquery-1.7.2.min.js"></script>
    <script src="/wish/Public/Js/index.js"></script>
    <script src="/wish/Public/layer/layer.js"></script>
    <style>
        #send-form.title{
            background: skyblue;
        }
    </style>
</head>
<body>
<div id='top'>
    <span id='send'></span>
</div>
    <div id='main'>
        <?php if(is_array($view)): $i = 0; $__LIST__ = $view;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$view): $mod = ($i % 2 );++$i;?><dl class='paper a<?php echo mt_rand(1,5);?>'>
            <dt>
                <span class='username'><?php echo ($view["username"]); ?></span>
                <span class='num'>No.<?php echo ($view["id"]); ?></span>
            </dt>
            <dd class='content'><?php echo (phiz($view["content"])); ?></dd>
            <dd class='bottom'>
                <span class='time'><?php echo (date('Y-m-d H:i',$view["time"])); ?></span>
                <a href="" class='close'></a>
            </dd>
        </dl><?php endforeach; endif; else: echo "" ;endif; ?>
    </div>
    <div id='send-form'>
        <p class='title'><span>许下你的愿望</span><a href="" id='close'></a></p>
        <form  name='wish'>
            <p>
                <label for="username">昵称：</label>
                <input type="text" name='username' id='username'/>
            </p>
            <p>
                <label for="content">愿望：(您还可以输入&nbsp;<span id='font-num'>50</span>&nbsp;个字)</label>
                <textarea name="content" id='content'></textarea>
            <div id='phiz'>
                <img src="/wish/Public/Images/phiz/zhuakuang.gif" alt="抓狂" />
                <img src="/wish/Public/Images/phiz/baobao.gif" alt="抱抱" />
                <img src="/wish/Public/Images/phiz/haixiu.gif" alt="害羞" />
                <img src="/wish/Public/Images/phiz/ku.gif" alt="酷" />
                <img src="/wish/Public/Images/phiz/xixi.gif" alt="嘻嘻" />
                <img src="/wish/Public/Images/phiz/taikaixin.gif" alt="太开心" />
                <img src="/wish/Public/Images/phiz/touxiao.gif" alt="偷笑" />
                <img src="/wish/Public/Images/phiz/qian.gif" alt="钱" />
                <img src="/wish/Public/Images/phiz/huaxin.gif" alt="花心" />
                <img src="/wish/Public/Images/phiz/jiyan.gif" alt="挤眼" />
            </div>
            </p>
            <span id='send-btn'></span>
            <!--<input type="submit" value="提交"/>-->
            <script>
                $(function(){
                    $('#send-btn').click(function(){
                        var username=$('#username').val();
                        var content=$('#content').val();

                        if(!username){
                            layer.alert('昵称不能为空',{icon:2,title:'错误提示'})
                        }else if(!content){
                            layer.alert('内容不能为空',{icon:2,title:'错误提示'})
                        }else{
                            var url="<?php echo U('Board/handle');?>";
                            $.post(url,{'username':username,'content':content},function(data){
                                if(data.id){
                                    var str="<dl class='paper a<?php echo mt_rand(1,5);?>'>";
                                        str+="<dt>";
                                        str+="<span class='username'>"+data.username+"</span>";
                                        str+="<span class='num'>No."+data.id+"</span>";
                                        str+="</dt>"
                                        str+="<dd class='content'>"+data.content+"</dd>";
                                        str+="<dd class='bottom'>";
                                        str+="<span class='time'>"+data.time+"</span>";
                                        str+="<a href='' class='close'></a>";
                                        str+="</dd>";
                                        str+="</dl>";
                                    $("#main").append(str);
                                    $("#close").click();
                                }else{
                                    layer.alert(data,{icon:2,title:'错误提示'});
                                }
                            },'json')
                        }
                    })
                })
            </script>
        </form>
    </div>
</body>
</html>